﻿// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com

// ReSharper disable CheckNamespace
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable CommentTypo
// ReSharper disable IdentifierTypo
// ReSharper disable InconsistentNaming
// ReSharper disable StringLiteralTypo
// ReSharper disable UnusedParameter.Local

/* AbstractQRCode.cs --
 * Ars Magna project, http://arsmagna.ru
 */

#nullable enable

namespace AM.Drawing.QRCoding;

/// <summary>
/// Абстрактный QR-код.
/// </summary>
public abstract class AbstractQRCode
{
    #region Properties

    /// <summary>
    /// Данные.
    /// </summary>
    protected QRCodeData? QrCodeData { get; set; }

    #endregion

    #region Construction

    /// <summary>
    /// Конструктор по умолчанию.
    /// </summary>
    protected AbstractQRCode()
    {
        // пустое тело конструктора
    }

    /// <summary>
    /// Конструктор.
    /// </summary>
    protected AbstractQRCode
        (
            QRCodeData data
        )
    {
        Sure.NotNull (data);

        QrCodeData = data;
    }

    #endregion

    #region Public methods

    /// <summary>
    /// Set a QRCodeData object that will be used to generate QR code. Used in COM Objects connections
    /// </summary>
    /// <param name="data">Need a QRCodeData object generated by QRCodeGenerator.CreateQrCode()</param>
    public virtual void SetQRCodeData
        (
            QRCodeData data
        )
    {
        Sure.NotNull (data);

        QrCodeData = data;
    }

    /// <summary>
    /// Избавляемся от данных.
    /// </summary>
    public void Dispose()
    {
        QrCodeData?.Dispose();
        QrCodeData = null;
    }

    #endregion
}
